package net.j4love.spring.framework.x5.ioc;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author he peng
 * @create 2017/12/12 16:08
 * @see
 */
public class IocContainerTest {

    static final Logger LOG = LoggerFactory.getLogger(IocContainerTest.class);


    @Test
    public void iocContainerInit() throws Exception {
        String classPathXmlPath = "5.x/applicationContext-ioc.xml";
        LOG.info("Initialized Spring IoC Container from xml file : {} " , classPathXmlPath);
        ClassPathXmlApplicationContext xmlApplicationContext =
                    new ClassPathXmlApplicationContext("classpath*:" + classPathXmlPath);

        xmlApplicationContext.start();
    }

    @Test
    public void iocContainerInitUseParent() throws Exception {
        ClassPathXmlApplicationContext parentAppContext = new ClassPathXmlApplicationContext("classpath*:5.x/applicationContext-resources.xml");
        String[] configLocations = {"classpath*:5.x/applicationContext-ioc.xml"};
        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(configLocations , true , parentAppContext);
        LOG.info("appContext ==> {} " , appContext);
    }
}
